{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from keras.models import Model\n",
    "from keras.layers import Input\n",
    "from keras.layers.convolutional import Conv1D\n",
    "from keras import backend as K\n",
    "import json\n",
    "from collections import OrderedDict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def format_decimal(arr, places=6):\n",
    "    return [round(x * 10**places) / 10**places for x in arr]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "DATA = OrderedDict()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Conv1D"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[convolutional.Conv1D.0] 4 length 3 filters on 5x2 input, strides=1, padding='valid', dilation_rate=1, activation='linear', use_bias=True**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W shape: (3, 2, 4)\n",
      "W: [0.895265, -0.546905, 0.18884, -0.143383, 0.528281, -0.994279, -0.285153, 0.81939, -0.087838, 0.963605, 0.734714, 0.972055, 0.846533, -0.392613, 0.692207, -0.757556, 0.571153, -0.49899, -0.807941, 0.886982, 0.6521, 0.03665, 0.747001, 0.156751]\n",
      "b shape: (4,)\n",
      "b: [0.895265, -0.546905, 0.18884, -0.143383]\n",
      "\n",
      "in shape: (5, 2)\n",
      "in: [0.528281, -0.994279, -0.285153, 0.81939, -0.087838, 0.963605, 0.734714, 0.972055, 0.846533, -0.392613]\n",
      "out shape: (3, 4)\n",
      "out: [2.139843, -0.364566, 1.720586, -1.858613, 2.949797, -1.99961, 0.63634, 0.557583, 2.311499, -1.567427, 0.132915, 1.325894]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (5, 2)\n",
    "conv = Conv1D(4, 3, strides=1, padding='valid', dilation_rate=1, activation='linear', use_bias=True)\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = conv(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "weights = []\n",
    "for w in model.get_weights():\n",
    "    np.random.seed(200)\n",
    "    weights.append(2 * np.random.random(w.shape) - 1)\n",
    "model.set_weights(weights)\n",
    "print('W shape:', weights[0].shape)\n",
    "print('W:', format_decimal(weights[0].ravel().tolist()))\n",
    "print('b shape:', weights[1].shape)\n",
    "print('b:', format_decimal(weights[1].ravel().tolist()))\n",
    "\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['convolutional.Conv1D.0'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in weights],\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[convolutional.Conv1D.1] 4 length 3 filters on 6x3 input, strides=1, padding='valid', dilation_rate=1, activation='linear', use_bias=False**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W shape: (3, 3, 4)\n",
      "W: [-0.772191, 0.495762, 0.222119, 0.619384, 0.425715, -0.719926, -0.464976, -0.704791, -0.543864, -0.528877, 0.380048, -0.703304, -0.108788, 0.401685, -0.806723, 0.765265, 0.739665, 0.689188, -0.452596, 0.571359, 0.402272, -0.010539, 0.672675, -0.191632, -0.653554, -0.269196, 0.994178, -0.318691, 0.010759, 0.078695, -0.501326, 0.625487, -0.614715, -0.839499, -0.811676, -0.300069]\n",
      "\n",
      "in shape: (6, 3)\n",
      "in: [0.57107, 0.361384, -0.924121, -0.417132, -0.39254, 0.967698, -0.674584, 0.924125, 0.403362, 0.417301, 0.795356, -0.367641, -0.398474, 0.889135, -0.81216, 0.383587, 0.922044, 0.427167]\n",
      "out shape: (4, 4)\n",
      "out: [0.562644, -0.0209, -0.688625, 0.691985, 0.509712, 0.184573, 1.169463, -0.253006, 1.859194, 0.365631, -1.552851, 0.418241, 0.087247, -0.099305, -1.471745, 0.641488]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (6, 3)\n",
    "conv = Conv1D(4, 3, strides=1, padding='valid', dilation_rate=1, activation='linear', use_bias=False)\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = conv(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "weights = []\n",
    "for w in model.get_weights():\n",
    "    np.random.seed(201)\n",
    "    weights.append(2 * np.random.random(w.shape) - 1)\n",
    "model.set_weights(weights)\n",
    "print('W shape:', weights[0].shape)\n",
    "print('W:', format_decimal(weights[0].ravel().tolist()))\n",
    "\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['convolutional.Conv1D.1'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in weights],\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[convolutional.Conv1D.2] 2 length 3 filters on 4x6 input, strides=2, padding='same', dilation_rate=1, activation='sigmoid', use_bias=True**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W shape: (3, 6, 2)\n",
      "W: [-0.551588, -0.471891, 0.954722, 0.985875, 0.989984, 0.142951, 0.199214, -0.77135, 0.620047, -0.536272, 0.982087, 0.105264, -0.122463, -0.826014, -0.123274, 0.745688, -0.177555, 0.48653, -0.563309, 0.742258, 0.105234, -0.612634, -0.136424, 0.508816, -0.070758, -0.433574, 0.764417, -0.312426, 0.834869, 0.612829, -0.226705, -0.66213, -0.646237, -0.9437, -0.924491, -0.352889]\n",
      "b shape: (2,)\n",
      "b: [-0.551588, -0.471891]\n",
      "\n",
      "in shape: (4, 6)\n",
      "in: [0.954722, 0.985875, 0.989984, 0.142951, 0.199214, -0.77135, 0.620047, -0.536272, 0.982087, 0.105264, -0.122463, -0.826014, -0.123274, 0.745688, -0.177555, 0.48653, -0.563309, 0.742258, 0.105234, -0.612634, -0.136424, 0.508816, -0.070758, -0.433574]\n",
      "out shape: (2, 2)\n",
      "out: [0.52296, 0.240592, 0.59414, 0.472844]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 6)\n",
    "conv = Conv1D(2, 3, strides=2, padding='same', dilation_rate=1, activation='sigmoid', use_bias=True)\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = conv(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "weights = []\n",
    "for w in model.get_weights():\n",
    "    np.random.seed(202)\n",
    "    weights.append(2 * np.random.random(w.shape) - 1)\n",
    "model.set_weights(weights)\n",
    "print('W shape:', weights[0].shape)\n",
    "print('W:', format_decimal(weights[0].ravel().tolist()))\n",
    "print('b shape:', weights[1].shape)\n",
    "print('b:', format_decimal(weights[1].ravel().tolist()))\n",
    "\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['convolutional.Conv1D.2'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in weights],\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[convolutional.Conv1D.3] 2 length 7 filters on 8x3 input, strides=1, padding='same', dilation_rate=1, activation='tanh', use_bias=True**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W shape: (7, 3, 2)\n",
      "W: [0.6958, -0.622123, -0.098786, 0.250694, 0.939495, -0.584387, 0.188897, 0.822914, -0.508628, 0.548608, 0.272553, 0.576978, 0.760404, -0.268837, 0.186754, 0.011788, 0.250571, 0.311674, -0.975276, 0.044954, 0.390867, 0.832295, -0.068466, -0.487965, -0.706554, 0.938197, 0.769853, -0.84513, 0.106441, 0.882159, -0.35372, 0.642428, -0.58288, -0.115854, -0.42362, -0.852597, 0.792338, -0.100119, -0.871574, -0.320701, 0.797559, 0.78815]\n",
      "b shape: (2,)\n",
      "b: [0.6958, -0.622123]\n",
      "\n",
      "in shape: (8, 3)\n",
      "in: [-0.098786, 0.250694, 0.939495, -0.584387, 0.188897, 0.822914, -0.508628, 0.548608, 0.272553, 0.576978, 0.760404, -0.268837, 0.186754, 0.011788, 0.250571, 0.311674, -0.975276, 0.044954, 0.390867, 0.832295, -0.068466, -0.487965, -0.706554, 0.938197]\n",
      "out shape: (8, 2)\n",
      "out: [0.662022, -0.963639, 0.970752, -0.525575, 0.983593, 0.519924, 0.722247, 0.354002, 0.444907, 0.884876, 0.25032, -0.947914, 0.654293, 0.86192, 0.975655, -0.980825]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (8, 3)\n",
    "conv = Conv1D(2, 7, strides=1, padding='same', dilation_rate=1, activation='tanh', use_bias=True)\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = conv(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "weights = []\n",
    "for w in model.get_weights():\n",
    "    np.random.seed(203)\n",
    "    weights.append(2 * np.random.random(w.shape) - 1)\n",
    "model.set_weights(weights)\n",
    "print('W shape:', weights[0].shape)\n",
    "print('W:', format_decimal(weights[0].ravel().tolist()))\n",
    "print('b shape:', weights[1].shape)\n",
    "print('b:', format_decimal(weights[1].ravel().tolist()))\n",
    "\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['convolutional.Conv1D.3'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in weights],\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[convolutional.Conv1D.4] 2 length 7 filters on 8x3 input, strides=1, padding='same', dilation_rate=2, activation='tanh', use_bias=True**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W shape: (7, 3, 2)\n",
      "W: [0.861113, -0.237594, 0.330694, 0.998309, 0.786447, 0.538158, -0.228315, 0.217332, -0.475436, -0.018066, -0.489741, -0.522387, 0.79989, 0.27058, -0.683115, -0.650208, 0.259853, -0.509243, 0.958185, 0.089546, 0.739799, 0.114385, -0.378872, -0.168716, 0.302124, 0.850416, -0.984343, 0.839927, -0.895196, 0.303711, 0.128826, 0.058159, 0.254989, -0.759101, 0.793844, 0.647309, 0.252074, 0.075576, -0.859305, 0.952613, -0.053285, -0.677361]\n",
      "b shape: (2,)\n",
      "b: [0.861113, -0.237594]\n",
      "\n",
      "in shape: (8, 3)\n",
      "in: [0.330694, 0.998309, 0.786447, 0.538158, -0.228315, 0.217332, -0.475436, -0.018066, -0.489741, -0.522387, 0.79989, 0.27058, -0.683115, -0.650208, 0.259853, -0.509243, 0.958185, 0.089546, 0.739799, 0.114385, -0.378872, -0.168716, 0.302124, 0.850416]\n",
      "out shape: (8, 2)\n",
      "out: [0.963457, 0.243838, -0.158206, -0.736323, 0.370836, -0.986532, 0.780216, 0.575109, -0.874838, -0.03132, -0.791811, -0.545406, 0.99756, 0.906116, -0.26601, -0.932366]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (8, 3)\n",
    "conv = Conv1D(2, 7, strides=1, padding='same', dilation_rate=2, activation='tanh', use_bias=True)\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = conv(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "weights = []\n",
    "for w in model.get_weights():\n",
    "    np.random.seed(204)\n",
    "    weights.append(2 * np.random.random(w.shape) - 1)\n",
    "model.set_weights(weights)\n",
    "print('W shape:', weights[0].shape)\n",
    "print('W:', format_decimal(weights[0].ravel().tolist()))\n",
    "print('b shape:', weights[1].shape)\n",
    "print('b:', format_decimal(weights[1].ravel().tolist()))\n",
    "\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['convolutional.Conv1D.4'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in weights],\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### export for Keras.js tests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "filename = '../../../test/data/layers/convolutional/Conv1D.json'\n",
    "if not os.path.exists(os.path.dirname(filename)):\n",
    "    os.makedirs(os.path.dirname(filename))\n",
    "with open(filename, 'w') as f:\n",
    "    json.dump(DATA, f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"convolutional.Conv1D.0\": {\"input\": {\"data\": [0.528281, -0.994279, -0.285153, 0.81939, -0.087838, 0.963605, 0.734714, 0.972055, 0.846533, -0.392613], \"shape\": [5, 2]}, \"weights\": [{\"data\": [0.895265, -0.546905, 0.18884, -0.143383, 0.528281, -0.994279, -0.285153, 0.81939, -0.087838, 0.963605, 0.734714, 0.972055, 0.846533, -0.392613, 0.692207, -0.757556, 0.571153, -0.49899, -0.807941, 0.886982, 0.6521, 0.03665, 0.747001, 0.156751], \"shape\": [3, 2, 4]}, {\"data\": [0.895265, -0.546905, 0.18884, -0.143383], \"shape\": [4]}], \"expected\": {\"data\": [2.139843, -0.364566, 1.720586, -1.858613, 2.949797, -1.99961, 0.63634, 0.557583, 2.311499, -1.567427, 0.132915, 1.325894], \"shape\": [3, 4]}}, \"convolutional.Conv1D.1\": {\"input\": {\"data\": [0.57107, 0.361384, -0.924121, -0.417132, -0.39254, 0.967698, -0.674584, 0.924125, 0.403362, 0.417301, 0.795356, -0.367641, -0.398474, 0.889135, -0.81216, 0.383587, 0.922044, 0.427167], \"shape\": [6, 3]}, \"weights\": [{\"data\": [-0.772191, 0.495762, 0.222119, 0.619384, 0.425715, -0.719926, -0.464976, -0.704791, -0.543864, -0.528877, 0.380048, -0.703304, -0.108788, 0.401685, -0.806723, 0.765265, 0.739665, 0.689188, -0.452596, 0.571359, 0.402272, -0.010539, 0.672675, -0.191632, -0.653554, -0.269196, 0.994178, -0.318691, 0.010759, 0.078695, -0.501326, 0.625487, -0.614715, -0.839499, -0.811676, -0.300069], \"shape\": [3, 3, 4]}], \"expected\": {\"data\": [0.562644, -0.0209, -0.688625, 0.691985, 0.509712, 0.184573, 1.169463, -0.253006, 1.859194, 0.365631, -1.552851, 0.418241, 0.087247, -0.099305, -1.471745, 0.641488], \"shape\": [4, 4]}}, \"convolutional.Conv1D.2\": {\"input\": {\"data\": [0.954722, 0.985875, 0.989984, 0.142951, 0.199214, -0.77135, 0.620047, -0.536272, 0.982087, 0.105264, -0.122463, -0.826014, -0.123274, 0.745688, -0.177555, 0.48653, -0.563309, 0.742258, 0.105234, -0.612634, -0.136424, 0.508816, -0.070758, -0.433574], \"shape\": [4, 6]}, \"weights\": [{\"data\": [-0.551588, -0.471891, 0.954722, 0.985875, 0.989984, 0.142951, 0.199214, -0.77135, 0.620047, -0.536272, 0.982087, 0.105264, -0.122463, -0.826014, -0.123274, 0.745688, -0.177555, 0.48653, -0.563309, 0.742258, 0.105234, -0.612634, -0.136424, 0.508816, -0.070758, -0.433574, 0.764417, -0.312426, 0.834869, 0.612829, -0.226705, -0.66213, -0.646237, -0.9437, -0.924491, -0.352889], \"shape\": [3, 6, 2]}, {\"data\": [-0.551588, -0.471891], \"shape\": [2]}], \"expected\": {\"data\": [0.52296, 0.240592, 0.59414, 0.472844], \"shape\": [2, 2]}}, \"convolutional.Conv1D.3\": {\"input\": {\"data\": [-0.098786, 0.250694, 0.939495, -0.584387, 0.188897, 0.822914, -0.508628, 0.548608, 0.272553, 0.576978, 0.760404, -0.268837, 0.186754, 0.011788, 0.250571, 0.311674, -0.975276, 0.044954, 0.390867, 0.832295, -0.068466, -0.487965, -0.706554, 0.938197], \"shape\": [8, 3]}, \"weights\": [{\"data\": [0.6958, -0.622123, -0.098786, 0.250694, 0.939495, -0.584387, 0.188897, 0.822914, -0.508628, 0.548608, 0.272553, 0.576978, 0.760404, -0.268837, 0.186754, 0.011788, 0.250571, 0.311674, -0.975276, 0.044954, 0.390867, 0.832295, -0.068466, -0.487965, -0.706554, 0.938197, 0.769853, -0.84513, 0.106441, 0.882159, -0.35372, 0.642428, -0.58288, -0.115854, -0.42362, -0.852597, 0.792338, -0.100119, -0.871574, -0.320701, 0.797559, 0.78815], \"shape\": [7, 3, 2]}, {\"data\": [0.6958, -0.622123], \"shape\": [2]}], \"expected\": {\"data\": [0.662022, -0.963639, 0.970752, -0.525575, 0.983593, 0.519924, 0.722247, 0.354002, 0.444907, 0.884876, 0.25032, -0.947914, 0.654293, 0.86192, 0.975655, -0.980825], \"shape\": [8, 2]}}, \"convolutional.Conv1D.4\": {\"input\": {\"data\": [0.330694, 0.998309, 0.786447, 0.538158, -0.228315, 0.217332, -0.475436, -0.018066, -0.489741, -0.522387, 0.79989, 0.27058, -0.683115, -0.650208, 0.259853, -0.509243, 0.958185, 0.089546, 0.739799, 0.114385, -0.378872, -0.168716, 0.302124, 0.850416], \"shape\": [8, 3]}, \"weights\": [{\"data\": [0.861113, -0.237594, 0.330694, 0.998309, 0.786447, 0.538158, -0.228315, 0.217332, -0.475436, -0.018066, -0.489741, -0.522387, 0.79989, 0.27058, -0.683115, -0.650208, 0.259853, -0.509243, 0.958185, 0.089546, 0.739799, 0.114385, -0.378872, -0.168716, 0.302124, 0.850416, -0.984343, 0.839927, -0.895196, 0.303711, 0.128826, 0.058159, 0.254989, -0.759101, 0.793844, 0.647309, 0.252074, 0.075576, -0.859305, 0.952613, -0.053285, -0.677361], \"shape\": [7, 3, 2]}, {\"data\": [0.861113, -0.237594], \"shape\": [2]}], \"expected\": {\"data\": [0.963457, 0.243838, -0.158206, -0.736323, 0.370836, -0.986532, 0.780216, 0.575109, -0.874838, -0.03132, -0.791811, -0.545406, 0.99756, 0.906116, -0.26601, -0.932366], \"shape\": [8, 2]}}}\n"
     ]
    }
   ],
   "source": [
    "print(json.dumps(DATA))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
